import 'package:get/get.dart';
import 'package:pornhub_app/components/diolog/loading/loading_view.dart';
import 'package:pornhub_app/http/api/api.dart';
import 'package:pornhub_app/model/community/community_model.dart';

class PostDetailsPageController extends GetxController {
  final getArguments = Get.arguments;

  var dynamicId;
  var dynamicModel = CommunityModel().obs;

  @override
  void onInit() {
    dynamicId = getArguments["dynamicId"];
    dynamicModel.value = getArguments["dynamicModel"];
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
    getDynamicDetails();
  }

  getDynamicDetails() {
    LoadingView.singleton.wrap(
        context: Get.context!,
        asyncFunction: () async {
          Api.getCommunityDynamicDetails(dynamicId: dynamicId).then((response) {
            if (response != null) {
              dynamicModel.value = response;
            }
          });
        });
  }
}
